package com.cl.core.controller;

import com.alibaba.fastjson.JSONObject;
import com.cl.core.builder.BuilderFactory;
import com.cl.utility.constant.Message;
import com.cl.utility.pojo.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
 * @author liddhappy
 * @description 建造接口
 * @createTime 2022/12/28 20:51
 */
@RestController
@RequestMapping("/builder")
@Api(tags = "建造者接口")
public class BuilderController {


    @PostMapping("/generate/sql")
    @ApiOperation(value = "生成sql",notes = "builderName,builderConfig,target,data(BuilderModel)")
    public ResultCode<List<T>> generateSQL(@RequestBody JSONObject materials) throws Exception {
        List<T> results = new ArrayList();
        BuilderFactory.builderProcessing(materials, results);
        return new ResultCode<>(Message.Success(), results);
    }
}
